home *** CD-ROM | disk | FTP | other *** search
- Path: gate.net!pslfl2-10
- From: bhutto@gate.net (William Hutto)
- Newsgroups: comp.lang.c
- Subject: Re: Problem with stringcopy
- Date: 8 Jan 1996 09:57:19 GMT
- Organization: CyberGate, Inc.
- Message-ID: <4cqppv$1quo@news.gate.net>
- References: <4clguu$9fs@eagle.novo.dk> <820933963snz@genesis.demon.co.uk> <4cq9dr$if9@ns.RezoNet.NET>
- NNTP-Posting-Host: pslfl2-10.gate.net
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- In article <4cq9dr$if9@ns.RezoNet.NET>,
- ray@ultimate-tech.com (Ray Dunn) wrote:
- >In referenced article, Lawrence Kirby says...
- >>Morten Brun writes:
- >>
- >>>How do i do a partial stringcopy i.e. copy from a specific position
- >>>in a string and a certain numbers of bytes. I am looking for a
- >>>function like target = Stringcopy(source, startpos, length)
- >>
- >>target[0] = '\0';
- >>strncat(target, source+startpos, length);
- >
- >....but use strncpy if you are overwriting some existing characters in
- >target and don't want the target string to terminate after the copied
- >characters.
-
- Considering strncpy()'s shortcomings, I amend my code:
-
- char destination[ > max_length];
-
- strncpy(destination,&source[startpos],max_length);
- destination[max_length]='\0';
-
- Bill
-
- "Whatcha got on?...Your mind?"
-